# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  
  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => '8f4fe9d97c85f7690e79c03a4baeb8d6'
    
  def get_user
    if session[:user].nil?
      redirect_to "edu"
    else
      @user = session[:user]
    end
  end
  
  def determin_layout
    get_user
    if @user.juese == "学生"
      "students"
    elsif @user.juese =="教师"
      "teachers"
    else
      "admin"
    end
  end

end
